
#https://www.modb.pro/db/89600

import pandas as pd
def excel_to_dict_list(path):
    # 读取Excel文件
    df = pd.read_excel(path)
    head_list=list(df.columns)  # 获取数据的列名称
    list_dic=[]  # 创建一个空列表

    for i in df.values:
        a_line=dict(zip(head_list, i))  # 将每行数据和列名称转换成字典
        list_dic.append(a_line)  # 将字典追加到列表上
    return list_dic


if __name__ == '__main__':
    dict_list = excel_to_dict_list('testExcel/excel转成dict数组.xls')
    print(dict_list)